<template>
  <div class="app-container">
    <el-form :model="selectForm" ref="queryForm" :inline="true" label-width="120px">
      <el-form-item label="计划编号：">
        <el-input size="small"  v-model="selectForm.planCode" placeholder="请输入计划编号" clearable/>
      </el-form-item>
      <el-form-item label="设备编号：">
        <el-input size="small"  v-model="selectForm.deviceId" placeholder="请输入设备编号" clearable/>
      </el-form-item>
      <el-form-item label="设备名称：">
        <el-input size="small"  v-model="selectForm.deviceName" placeholder="请输入设备名称" clearable/>
      </el-form-item>
      <el-form-item label="计划单位/部门：">
        <el-input size="small"  v-model="selectForm.meteringDept" placeholder="请输入计划单位/部门" clearable/>
      </el-form-item>
      <el-form-item label="计划类型：">
        <el-select size="small" v-model="selectForm.planType" placeholder="请选择" clearable>
          <el-option
            v-for="item in [{value: '1',label: '计量'},{value: '2',label: '核查'}]"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="内外部：">
        <el-select size="small" v-model="selectForm.inoutMetering" placeholder="请选择" clearable>
          <el-option
            v-for="item in [{value: '1',label: '内部'},{value: '2',label: '外部'}]"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="下次定检日期：">
        <el-date-picker
          size="small"
          v-model="selectDate"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          @change="dateChange"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button size="mini" type="primary" icon="el-icon-search">搜索</el-button>
        <el-button size="mini" type="success" icon="el-icon-plus" @click="add">添加</el-button>
        <el-button size="mini" type="info" icon="el-icon-upload">导入</el-button>
        <el-button size="mini" type="warning" icon="el-icon-download">导出</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="list" stripe border>
      <el-table-column align="center" type="index" label="序号" width="55"/>
      <el-table-column align="center" label="计划编号" width="150">
        <template slot-scope="scope">
          <span class="bule" @click="details(scope.row)">{{scope.row.planCode}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" label="负责人" prop=""/>
      <el-table-column align="center" label="设备名称" prop="deviceName" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="设备编号" prop="deviceId" :show-overflow-tooltip="true"/>
      <el-table-column align="center" label="计划类型">
        <template slot-scope="scope">
          <template v-if="scope.row.planType==1">计量</template>
          <template v-if="scope.row.planType==2">核查</template>
        </template>
      </el-table-column>
      <el-table-column align="center" label="内外部计量">
        <template slot-scope="scope">
          <template v-if="scope.row.inoutMetering==1">内部</template>
          <template v-if="scope.row.inoutMetering==2">外部</template>
        </template>
      </el-table-column>
      <el-table-column align="center" label="计量单位/部门" prop="meteringDept"/>
      <el-table-column align="center" label="提前提醒时间" prop="noticeDate">
        <template slot-scope="scope">
          {{scope.row.noticeDate}}
          {{scope.row.noticeUnit}}
        </template>
      </el-table-column>
      <el-table-column align="center" label="检定周期" prop="noticeDate">
        <template slot-scope="scope">
          {{scope.row.meteringDate}}
          {{scope.row.meteringUnit}}
        </template>
      </el-table-column>
      <el-table-column label="下次定检日期" align="center" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.nextMeteringDate) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="150" fixed="right">
        <template slot-scope="scope">
          <el-button size="mini" type="primary" icon="el-icon-edit" @click="edit(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      :total="total"
      :page.sync="selectForm.pageNum"
      :limit.sync="selectForm.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  export default {
    name: "metrologicalPlan.vue",
    data() {
      return {
        loading: false,//加载
        selectForm: {
          planCode: '',//计划编号
          deviceId: '',//设备编号
          deviceName: '',//设备名称
          meteringDept: '',//计划单位/部门
          planType: '',//计划类型
          inoutMetering: '',// 内外部1内2外
          nextMeteringDate: '',//下次定检日期
          pageNum: 1,
          pageSize: 10,
        },//查询条件
        list: [
          {
            planCode: 'CGJH2020000265',
            deviceId: 'CGJH2020000265',
            deviceName: '测试',
            meteringDept: '测试',
            planType: 1,
            inoutMetering: 1,
            nextMeteringDate: '2020-10-02',
            noticeDate:'4',
            noticeUnit:'日',
            meteringDate:'4',
            meteringUnit:'日',
          },
          {
            planCode: 'CGJH2020000265',
            deviceId: 'CGJH2020000265',
            deviceName: '测试',
            meteringDept: '测试',
            planType: 1,
            inoutMetering: 1,
            nextMeteringDate: '2020-10-02',
            noticeDate:'4',
            noticeUnit:'日',
            meteringDate:'4',
            meteringUnit:'日',
          }
        ],//数据
        total: 2,
        selectDate: '',//时间
      }
    },
    created() {
    },
    methods: {
      getList() {

      },
      //更改时间
      dateChange() {
        console.log(this.selectDate)
        this.selectForm.nextMeteringDate = this.selectDate
      },
      edit(row) {
        this.$router.push({path:'/metrological/add',query:{data:row}});
      },
      add(){
        this.$router.push({path:'/metrological/add'});
      },
      details(row){
        console.log(row);
        this.$router.push({path:'/metrological/detail',query:{data:row}});
      }
    }
  }
</script>

<style scoped>
  .bule {
    color: #2196F3;
    cursor: pointer
  }
</style>
